package com.example.slidingui;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class ContentFragment extends Fragment {
	private static final String TAG = "ContentFragment";

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
//		Log.d(TAG, "onAttach()" + getActivity());
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		Log.d(TAG, "onCreate()" + getActivity());
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//		Log.d(TAG, "onCreateView()" + getActivity());
		return inflater.inflate(R.layout.fragment_content, null);
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
//		Log.d(TAG, "onViewCreated()" + getActivity());
		String action = "action";
		Bundle args = getArguments();
		if (args != null) {
			action += args.getInt("action");
		}

		view.findViewById(R.id.btnMenu).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				Log.d(TAG, "onClick()" + getActivity());
				// open menu
				Activity a = getActivity();
				if (a instanceof MainActivity) {
					((MainActivity) a).toggleMenu();
				}
			}
		});
		view.findViewById(R.id.btnTest).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				Log.d(TAG, "onClick()" + getActivity());
			}
		});

		TextView text = (TextView) view.findViewById(R.id.text);
		text.setText(action);
	}
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
//		Log.d(TAG, "onActivityCreated()" + getActivity());
		super.onActivityCreated(savedInstanceState);
	}

	@Override
	public void onPause() {
//		Log.d(TAG, "onPause()" + getActivity());
		super.onPause();
	}

	@Override
	public void onDestroy() {
//		Log.d(TAG, "onDestroy()" + getActivity());
		super.onDestroy();
	}

	@Override
	public void onDetach() {
//		Log.d(TAG, "onDetach()" + getActivity());
		super.onDetach();
	}
}
